package com.stox.services.data.provider.repository.file.iterator;

import java.util.Date;

import com.stox.shared.core.model.Bar;

public class StartAndEndAwareBarIterator extends BarSpanAwareBarIterator {

	private final Date start;
	
	private final Date end;
	
	public StartAndEndAwareBarIterator(Date start, Date end) {
		this.start = start;
		this.end = end;
	}
	
	@Override
	public boolean shouldContinue(Bar bar) {
		if(bar.getDate().after(start)){
			return true;
		}
		
		super.shouldContinue(bar);
		
		if(bar.getDate().before(end) || bar.getDate().equals(end)){
			return false;
		}
		return true;
	}

}
